package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo9 {
    public static void main(String[] args) {
        try {
            Connection connection=DBUtil.getConnection();
            Statement statement=connection.createStatement();
            String sql="select  count(*) count from class c join student s on c.id=s.class_id where c.name='1年级1班'";
            //PreparedStatement ps=connection.prepareStatement(sql);
            //ps.setString(1,"1年级1班");
            ResultSet resultSet=statement.executeQuery(sql);
            while(resultSet.next()){
                int count=resultSet.getInt("count");
                System.out.println(count);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
